<?php
/*
 * Loads the sitetalk.ini configuration file and sets/overrides other
 * properties and settings.
 */
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."Tool.php";
$doc_dir = dirname(__FILE__).DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..";

$config_dir = $doc_dir.DIRECTORY_SEPARATOR.'_config';
if(!file_exists ($config_dir)){
	$config_dir = dirname($doc_dir).DIRECTORY_SEPARATOR.'_config';
}

if(file_exists ($config_dir.DIRECTORY_SEPARATOR.'setting')){
	$properties = parse_ini_file ($config_dir.DIRECTORY_SEPARATOR.'setting'.DIRECTORY_SEPARATOR.'setting.ini');
} else {
	$properties = parse_ini_file ($config_dir.DIRECTORY_SEPARATOR.'setting.ini');
}



$arrProperties = array("BArt_system_MYSQL_HOST" => false,
					   "BArt_system_MYSQL_NAME" => false,
					   "BArt_system_MYSQL_USER" => false,
					   "BArt_system_MYSQL_PASS" => false,
					   "BArt_system_MYSQL_DEBUG" => false
					  );

foreach ($arrProperties as $key => $value) {
	foreach ($properties as $id => $val) {
		if ($id == $key && !$value) {
		if(is_array($val))
			{
				define($id, Tool::decode(serialize($val), "sTunnInVietnAm@2012#")); //if you want to use SiteTalk_MemCache_Server_IP, use method : unserialize(SiteTalk_MemCache_Server_IP)
			}
			else
			{
				define($id, Tool::decode($val, "sTunnInVietnAm@2012#"));
			}
		}
	}
}
